package com.div.popup;

import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

public class PopupWindowActivity extends AppCompatActivity implements View.OnClickListener {

    private CustomPopwindow mPopupWindow;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        hideNavigationBar();
        setContentView(R.layout.layout_window_manager);
        findViewById(R.id.iv_popup).setOnClickListener(this);
        mPopupWindow = new CustomPopwindow(this)
                .setView(R.layout.layout_popup_window)
                .setFocusable(true)
                .setOutsideTouchable(true);
    }

    private void hideNavigationBar() {
        View decorView = getWindow().getDecorView();
        int flags = View.SYSTEM_UI_FLAG_FULLSCREEN
                |View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                |View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
        decorView.setSystemUiVisibility(flags);
    }

    @Override
    public void onClick(View v) {
        mPopupWindow.showAtLocationFullScreen(v);
//        mPopupWindow.showAtLocation(v);
    }
}
